package logic.courseQuery_logic;

import java.util.LinkedList;
import java.util.List;

import javaRMI.RMIClient;
import logic.utility_logic.CourseProduceLogicsvFactory;
import logicsv.courseProduce_logicsv.CourseProduceLogicsv;
import po.StuCouScoRecPO;
import resultmessage.CourseQueryRM;
import vo.CourseVO;
import datasv.courseQuery_datasv.CourseQueryDatasv;
import datasv.datafactorysv.CourseQueryDatasvFactory;

public class StuCouScoList {
	private CourseQueryDatasv courseQD;
	private CourseProduceLogicsv coursePL;
	public StuCouScoList(RMIClient rmi){
		courseQD = new CourseQueryDatasvFactory(rmi).create();
		coursePL = new CourseProduceLogicsvFactory(rmi).create();
	}
	public List<StuCouScoRecPO> getCourses(String studentID){
		return courseQD.getAllCouOfStu(studentID);
	}
	public List<CourseVO> getAllCouOfStu(String studentID){
		List<StuCouScoRecPO> courses  = courseQD.getAllCouOfStu(studentID);
		LinkedList<CourseVO> list = new LinkedList<CourseVO>();
		if(courses != null){
			for(StuCouScoRecPO rec : courses){
				list.add(coursePL.getCourse(rec.getCourseID()));
			}
		}
		return list;
	}
	public CourseQueryRM deleteStuOfCou(String courseID, String studentID) {
		return courseQD.deleteStuOfCou(courseID, studentID);
	}
	public CourseQueryRM addStuOfCou(String courseID, String studentID) {
		return courseQD.addStuOfCou(courseID, studentID);
	}

	public CourseQueryRM updateStuScoOfCou(String courseID, String studentID,
			int score) {
		return courseQD.updateStuOfCou(courseID, studentID, score);
	}

}
